/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package menu;

import java.io.Serializable;
import java.util.Collection;
import javax.persistence.Basic;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.Id;
import javax.persistence.NamedQueries;
import javax.persistence.NamedQuery;
import javax.persistence.OneToMany;
import javax.persistence.Table;
import javax.validation.constraints.NotNull;
import javax.validation.constraints.Size;
import javax.xml.bind.annotation.XmlRootElement;
import javax.xml.bind.annotation.XmlTransient;

/**
 *
 * @author abosancic
 */
@Entity
@Table(name = "drzava")
@XmlRootElement
@NamedQueries({
    @NamedQuery(name = "Drzava.findAll", query = "SELECT d FROM Drzava d"),
    @NamedQuery(name = "Drzava.findByIddrzave", query = "SELECT d FROM Drzava d WHERE d.iddrzave = :iddrzave"),
    @NamedQuery(name = "Drzava.findByNaziv", query = "SELECT d FROM Drzava d WHERE d.naziv = :naziv")})
public class Drzava implements Serializable {
    private static final long serialVersionUID = 1L;
    @Id
    @Basic(optional = false)
    @NotNull
    @Column(name = "iddrzave")
    private Integer iddrzave;
    @Size(max = 255)
    @Column(name = "naziv")
    private String naziv;
    @OneToMany(mappedBy = "iddrzave")
    private Collection<Mjesto> mjestoCollection;

    public Drzava() {
    }

    public Drzava(Integer iddrzave) {
        this.iddrzave = iddrzave;
    }

    public Integer getIddrzave() {
        return iddrzave;
    }

    public void setIddrzave(Integer iddrzave) {
        this.iddrzave = iddrzave;
    }

    public String getNaziv() {
        return naziv;
    }

    public void setNaziv(String naziv) {
        this.naziv = naziv;
    }

    @XmlTransient
    public Collection<Mjesto> getMjestoCollection() {
        return mjestoCollection;
    }

    public void setMjestoCollection(Collection<Mjesto> mjestoCollection) {
        this.mjestoCollection = mjestoCollection;
    }

    @Override
    public int hashCode() {
        int hash = 0;
        hash += (iddrzave != null ? iddrzave.hashCode() : 0);
        return hash;
    }

    @Override
    public boolean equals(Object object) {
        // TODO: Warning - this method won't work in the case the id fields are not set
        if (!(object instanceof Drzava)) {
            return false;
        }
        Drzava other = (Drzava) object;
        if ((this.iddrzave == null && other.iddrzave != null) || (this.iddrzave != null && !this.iddrzave.equals(other.iddrzave))) {
            return false;
        }
        return true;
    }

    @Override
    public String toString() {
        return "Drzava{" + "iddrzave=" + iddrzave + ", naziv=" + naziv + ", mjestoCollection=" + mjestoCollection + '}';
    }
    
}
